package cn.tlb.xutilsdownload.db;

import android.database.Cursor;

import org.xutils.db.converter.ColumnConverter;
import org.xutils.db.sqlite.ColumnDbType;

/**
 * Created by 汤林冰 on 2015/11/27 14:34.
 *
 * 提供了MyDate到String的转换
 */
public class MyDateConverter implements ColumnConverter<MyDate> {
    //通过cursor index位置的值得到自定义对象
    @Override
    public MyDate getFieldValue(Cursor cursor, int index) {
        return new MyDate(cursor.getString(index));
    }

    //将自定义对象转换为对应的类型(这里是String)
    @Override
    public String fieldValue2DbValue(MyDate fieldValue) {
        return fieldValue.toString();
    }

    //String属于varchar/text  枚举ColumnDbType中无varchar
    @Override
    public ColumnDbType getColumnDbType() {
        return ColumnDbType.TEXT;
    }
}
